import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      // imports配置哪些文件需要自动导包
      imports: ["vue", "vue-router", "pinia"],
      // 自定义一个文件位置和名称，其中可以看到不需要导包的变量
      dts: "src/auto-imports.d.ts",
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      // relative paths to the directory to search for components.
      // 使用 '**' 就可以递归地匹配src下面的每一层子目录
      dirs: ["src/**"],
      resolvers: [ElementPlusResolver()],
      dts: "src/vue-components.d.ts",
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
